package com.lzx.iteam.widget;


import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.HorizontalScrollView;
import com.lzx.iteam.SalaryFieldFormActivity;

public class CHScrollFieldView extends HorizontalScrollView {

	private static final String TAG = "CHScrollView";

	public static boolean firstRight = true;
	public static boolean firstLeft = true;

	SalaryFieldFormActivity activity;

	public CHScrollFieldView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		activity = (SalaryFieldFormActivity) context;
	}


	public CHScrollFieldView(Context context, AttributeSet attrs) {
		super(context, attrs);
		activity = (SalaryFieldFormActivity) context;
	}

	public CHScrollFieldView(Context context) {
		super(context);
		activity = (SalaryFieldFormActivity) context;
	}
	
	@Override
	public boolean onTouchEvent(MotionEvent ev) {
		//进行触摸赋值
		activity.mTouchView = this;
		return super.onTouchEvent(ev);
	}
	
	@Override
	protected void onScrollChanged(int l, int t, int oldl, int oldt) {
		//当当前的CHSCrollView被触摸时，滑动其它
		if(activity.mTouchView == this) {
			int  maxScrollX = getChildAt(0).getMeasuredWidth()-getMeasuredWidth();
			if (getScrollX() == 0 ) { //滑到最左
				Log.d(TAG, "turn  left "  );
			}else if (getScrollX() == maxScrollX) {  //滑到最右
			}else{
				activity.onScrollChanged(l, t, oldl, oldt);
			}
		}else{
			super.onScrollChanged(l, t, oldl, oldt);
		}
	}

}
